<?php
namespace App\Libs\Order;
use \Phalcon\DI;
use \App\Libs\Cache\Redis;
use \App\Libs\DB\PailePdo;
/**
 * 订单评价
 */
class OrderComment extends \App\Libs\Base\AccessObject
{

	/**
	*	获取评价信息
	*/
    public static function OrderCommentAll( $sid ){
		$sql = "SELECT num,sid,count(num) nowCount from t_paile_order_comment where sid = {$sid} GROUP BY sid,num";
		$result = PailePdo::findAll( $sql );
		//不为空则有评价信息 为空则 5分
		if( !empty( $result ) ){
			$totalCount = '0';
			foreach( $result as $k=>$v ){
				$totalCount += $v['nowCount'];
			}
			$score = 0;
			foreach( $result as $k=>$v ){
				$score += $v['num']*$v['nowCount']/$totalCount;	
			}
			$score = floor( $score );
		}else{
			$score = 5;
		}
		return $score; 
    }
	
}


